package day12;

import java.io.File;
import java.util.HashMap;

public class test02 {
    public static void main(String[] args) {
        File file=new File("E:\\cs_it heima\\jiuyeban\\study");
        HashMap<String,Integer> map=new HashMap<>();
        getCount(map,file);
    }

    private static void getCount(HashMap<String, Integer> map, File file) {
        File[] files = file.listFiles();
        for (File f : files) {
            if (f.isFile()){
                String name = f.getName();
                String[] fileNameArr = name.split("\\.");
                if (fileNameArr.length==2){
                    String fileEndName=fileNameArr[1];
                    if (map.containsKey(fileEndName)){
                        Integer count=map.get(fileEndName);
                        count++;
                        map.put(fileEndName,count);
                    }
                }

            }else {
                getCount(map,f);
            }
        }
    }
}
